<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Result output</title>
    <link rel="stylesheet" href="../../style/Output.css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript" src="../../javascript/JavaScript1.js"></script>
</head>
<?php
	include("../../database/connect.php");
	
    $complaint_id = $_GET["complaint_id"];
    if (empty($complaint_id)) {
        include("../../database//updateDB.php");
        $complaint_id = create_complaint();
    }
    $row = mysql_fetch_array(mysql_query("SELECT * FROM complaints WHERE complaint_id='$complaint_id'"));
    $sessionID = $row['sessionID'];
    
    $userInfo = mysql_query("SELECT * FROM users WHERE idNum IN (SELECT idNum FROM complaints WHERE complaint_id='$complaint_id')");
	$row = mysql_fetch_array($userInfo);
    $userID = $row['idNum'];
    $ageLine = ($row['sex'] == 'male' ? "בן " : "בת ") . $row['age'] . ", רקע כמתואר, ";
	$firstname = $row['firstName'];
	$lastname = $row['lastName'];
	$street = $row['streetAddress'];
	$city = $row['city'];
	$visit = ($row['visit'] == 'first' ? 'ראשון' : 'חוזר');
	switch ($row['status'])
	{
	case 'single':
  		$status = 'ר';
  	break;
	case 'married':
  		$status = 'נ';
  	break;
	case 'divorced':
  		$status = 'ג';
  	break;
	case 'widowed':
  		$status = 'א';
  	break;
	default:
		$status = 'ר';
	}
	if ($row['haskids'])
	{
		$status = $status . "+". $row['kids'];
	}
	switch ($row['occupation'])
	{
	case 'physical':
  		$occupation = 'עבודה פיזית';
  	break;
	case 'materials':
  		$occupation = 'עבודה עם חומרים';
  	break;
	case 'field':
  		$occupation = 'עבודת שטח';
  	break;
	default:
		$occupation = 'עבודה משרדית';
	}
	if ($row['retired'])
	{
		$occupation = $occupation . " (בפנסיה)";
	}
    
    $mainComp;
    $complaints = mysql_query("SELECT complaint FROM complaints WHERE idNum='$userID' AND sessionID='$sessionID'");
    while ($complaint = mysql_fetch_array($complaints)){
	if ($mainComp){
        $mainComp .= ", ";
    }
    switch ($complaint['complaint'])
	{
	case 'temperature':
  		$mainComp .= 'חום';
  	break;
	case 'nose':
  		$mainComp .= 'נזלת וגודש';
  	break;
	case 'weakness':
  		$mainComp .= 'חולשה';
  	break;
	case 'breath':
  		$mainComp .= 'קוצר נשימה';
  	break;
	case 'cough':
  		$mainComp .= 'שיעול';
  	break;
	case 'appetite':
  		$mainComp .= 'ירידה בתיאבון';
  	break;
	case 'pain':
  		$mainComp .= 'כאבים';
  	break;
	case 'weightloss':
  		$mainComp .= 'ירידה במשקל';
  	break;
	case 'vomating':
  		$mainComp .= 'הקאות';
  	break;
	case 'heartburn':
  		$mainComp .= 'צרבת';
  	break;
	case 'itch':
  		$mainComp .= 'גרד';
  	break;
	case 'skin':
  		$mainComp .= 'שינויים בצבע העור';
  	break;
	case 'wound':
  		$mainComp .= 'פצע';
  	break;
	case 'lump':
  		$mainComp .= 'גוש\גידול';
  	break;
	case 'palpitations':
  		$mainComp .= 'פלפיטציות(דפיקות לב חזקות או הרגשת קולות לב לא סדירים)';
  	break;
	case 'dizziness':
  		$mainComp .= 'סחרחורת';
  	break;
	case 'diarrhea':
  		$mainComp .= 'שלשולים';
  	break;
	case 'constipation':
  		$mainComp .= 'עצירות';
  	break;
	case 'urine':
  		$mainComp .= 'שינויים במתן שתן';
  	break;
	case 'gynecologist':
  		$mainComp .= 'בעיה גיניקולוגית';
  	break;
	case 'sexual':
  		$mainComp .= 'בעיה בתפקוד המיני';
  	break;
	case 'mood':
  		$mainComp .= 'דיכאון או בעיה אחרת הקשורה במצב הרוח';
  	break;
	default:
  		$mainComp .= 'אחר';
  	break;
	}
    }
    
?>

<body>

    <div id="demographic">
        <h3>פרטים דמוגרפיים</h3>
        <p>
            <a class="field">שם פרטי: </a>
            <a class="entry">
                <?php echo $firstname?>
            </a>
            <a class="field">שם משפחה: </a>
            <a class="entry">
                <?php echo $lastname?>
            </a>
            <a class="field">מגורים: </a>
            <a class="entry">
                <?php echo $street . ", " . $city . "<br />"?>
            </a>
            <a class="field">ביקור: </a>
            <a class="entry">
                <?php echo $visit . " "?>
            </a>
            <a class="field">מצב משפחתי: </a>
            <a class="entry">
                <?php echo $status . " "?>
            </a>
            <a class="field">מקצוע: </a>
            <a class="entry">
                <?php echo $occupation?>
            </a>
        </p>
    </div>

    <div id="mainComplaint">
        <h3>תלונה עיקרית</h3>
        <p>
            <a class="field"></a>
            <a class="field">
                <?php echo $mainComp?>
            </a>
        </p>
    </div>

    <div id="medicalBackground">
        <h3>רקע רפואי</h3>
        <?php
         include("displaybackground.php");
        ?>
    </div>

    <div id="complaintDetails">
        <h3>מחלה נוכחית</h3>

        <?php
		$i = 0;
        $complaintNames = mysql_query("SELECT complaint FROM complaints WHERE idNum='$userID' AND sessionID='$sessionID'");
        while ($row = mysql_fetch_array($complaintNames))
        {
            echo (($i == 0) ?  $ageLine : "בנוסף ");
            $currentComplaint = $row['complaint']; 
            switch ($currentComplaint)
            {
                case 'constipation':
                    include("displayConstipation.php");
                    continue;
                case 'temperature':
                    include("displayTemperature.php");
                    continue;
                case 'pain':
                    include("displaypain.php");
                    continue;
                case 'diarrhea':
                    include("displayDiarrhea.php");
                    break;
                case 'vomating':
                    include("displayVomiting.php");
                    break;
                default:
                    continue;
            }
            $i++;
            mysql_query("UPDATE complaints SET pending='0' WHERE complaint_id='$complaint_id'");
        }

        ?>
    </div>

    <div id="mentions">

        <h3>יש לציין</h3>
        <?php
         include("displayMentions.php");
        ?>

    </div>


</body>
</html>
